package com.ewili.x.special.service.data.impl;

import com.ewili.framework.utils.DateUtils;
import com.ewili.x.special.dao.inter.StockDao;
import com.ewili.x.special.entity.Stock;
import com.ewili.x.special.service.data.inter.HyRankService;
import com.ewili.x.special.task.thread.inter.HyRankThreadTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wonder
 */
@Service
public class HyRankServiceImpl implements HyRankService {

    @Autowired
    private StockDao stockDao;

    @Autowired
    private HyRankThreadTask hyRankThreadTask;

    @Override
    public void spideData() {
        List<Stock> stocks = stockDao.findAll();
        for (Stock stock : stocks) {
            String url = "http://quote.eastmoney.com/" + stock.getMarket() + stock.getCode() + ".html";
            hyRankThreadTask.spideData(url, stock.getCode(), DateUtils.currentDate(DateUtils.yyyy_MM_dd));
        }
    }
}
